{{template "base/base.html" .}}
{{define "head"}}
<title>sss</title>
{{end}}
{{define "body"}}
<div class="testing">
    <header class="main">
        <h1><strong>Retina</strong> Dashboard</h1>
        <!--<input type="text" value="search" />-->
    </header>
    <section class="user">
        <div class="profile-img">
            <p><img src="/static/images/uiface2.png" alt="" height="40" width="40" /> Welcome back John Doe</p>
        </div>
        <div class="buttons">
            <span class="button blue"><a href="/admin/login_out/{{.tel}}">登出</a></span>
        </div>
    </section>
</div>
<nav>
    <ul>
        <li><a href="/admin/index/{{.tel}}"><span class="icon">&#128711;</span> 设备监控</a></li>
        <li><a href="/admin/admin_list/{{.tel}}"><span class="icon">&#128101;</span>管理员<span class="pip">3</span></a></li>
        <li class="section">
            <a href="/admin/sys_setting/{{.tel}}"><span class="icon">&#9881;</span>系统设置</a>
        </li>
        <li>
            <a href="/admin/show_remote_list/{{.tel}}"><span class="icon">&#9881;</span>显示遥控数据</a>
        </li>
        <li>
            <a href="/admin/add_remote_data/{{.tel}}"><span class="icon">&#9881;</span>添加遥控数据</a>
        </li>
    </ul>
</nav>

<section class="content">
    <section class="widget">
        <header>
            <span class="icon">&#128100;</span>
            <hgroup>
                <h1>Users</h1>
                <h2>Current member accounts</h2>
            </hgroup>
            <aside>
				<span>
					<a href="#">&#9881;</a>
					<ul class="settings-dd">
                        <li><label>Option a</label><input type="checkbox" /></li>
                        <li><label>Option b</label><input type="checkbox" checked="checked" /></li>
                        <li><label>Option c</label><input type="checkbox" /></li>
                    </ul>
				</span>
            </aside>
        </header>
        <div class="content">
            <div id="sys_seting">
                <!-- <form id="register_form" >-->
                <div class="txt-fld">
                    <label for="">时间粒度大小</label>
                    <input type="text" class="sys_txt" value={{.particleSize}} id="ParticleSize" />
                    <button id="ParticleSize_btn" class="sys_btn" type="submit">确定</button>
                </div>
                <div class="txt-fld">
                    <label for=""> 自动控制状态</label>
                    <!--<input type="text" class="sys_txt" value={{.mahine_learn}} id="IsMashineLearn" />-->
                      <select class="sys_select" id="sys_select">
  						<option value="true">开启</option>
  						<option value="false">关闭</option>
					  </select>
                    <button id="IsMashineLearn_btn" class="sys_btn" type="submit">确定</button>

                </div>
                <div class="txt-fld">
                    <label for="">触发阀值</label>
                    <input type="text" class="sys_txt" value={{.thresholdValue}} id="ThresholdValue" />
                    <button id="ThresholdValue_btn" class="sys_btn" type="submit">确定</button>

                </div>
                <!--</form>-->
            </div>
        </div>
    </section>
</section>
<script type="text/javascript">
$(document).ready(function() {
	var mahine_learn = {{.mahine_learn}};
	
	console.log(mahine_learn == false)
		$("#sys_select option").each(function(item){	
			//console.log(($("#sys_select").get(0).options[item].value));
			//console.log(($("#sys_select").get(0).options[item].value) == mahine_learn.toString());
			
			if (($("#sys_select").get(0).options[item].value) == mahine_learn.toString()){
				//alert("s");
				$("#sys_select").get(0).options[item].selected = true;
			}
			//alert(item.val());//selected="selected"
			
		});
     $("#ParticleSize_btn").click(function(){
		 data = {'ParticleSize':$('#ParticleSize').val()}
         $.post('http://'+window.location.host+'/admin/api/save_particle_size',data,function(data){
				//console.log(data)
				if(data.RespCode == 200){
					//alert("添加用户成功");
					window.location.reload()
				}else{
					alert(data.Msg);
				}

			});
     });
	  $("#IsMashineLearn_btn").click(function(){
		 data = {'SysMashineLearn':$('#sys_select').val()}
		 //console.log($('#sys_select').val())
         $.post('http://'+window.location.host+'/admin/api/save_machine_learn',data,function(data){
				console.log(data)
				if(data.RespCode == 200){
					//alert("添加用户成功");
				}else{
					alert(data.Msg);
				}

			});
     });
	  $("#ThresholdValue_btn").click(function(){
		  alert($('#ThresholdValue').val())
		 data = {'ThresholdValue':$('#ThresholdValue').val()}
         $.post('http://'+window.location.host+'/admin/api/save_threshold',data,function(data){
				console.log(data)
				if(data.RespCode == 200){
					//alert("添加用户成功");
				}else{
					alert(data.Msg);
				}

			});
     });

});
</script>
{{end}}